/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.delivery.parcel.app.factory;

import com.delivery.parcel.model.AppUser;
import com.delivery.parcel.model.CustomerAddress;
import com.delivery.parcel.model.Employee;
import com.delivery.parcel.model.RegisteredUser;
import com.delivery.parcel.model.Roles;
import java.util.Map;

/**
 *
 * @author Malotana
 */
public class Factories {
    public static AppUser getUser(Map<String, String> details, boolean enabled, Roles roles){
        AppUser user = new AppUser();
        user.setEnabled(enabled);
        user.setUserName(details.get("username"));
        user.setPassword(details.get("password"));
        user.setRoles(roles);
        return user;
    }
    
    public static Roles getRole(Map<String, String> details){
        Roles role = new Roles();
        role.setRoleName(details.get("roleName"));
        role.setDescription(details.get("description"));
        role.setUsername(details.get("username"));
        
        return role;
    }
    
    public static RegisteredUser getRegUser(Map<String, String> details){
        RegisteredUser user = new RegisteredUser();
        user.setFirstname(details.get("firstname"));
        user.setLastname(details.get("lastname"));
        user.setPassword(details.get("password"));
        user.setEmail(details.get("email"));
        user.setCompassword(details.get("compassword"));
        return user;
    }
    
    public static CustomerAddress getCustomerAddress(Map<String, String>values){
        CustomerAddress customerAddress = new CustomerAddress();
        customerAddress.setStreetAddress(values.get("streetAddress"));
        customerAddress.setPostalAddress(values.get("postalAddress"));
        customerAddress.setPostalCode(values.get("postalCode"));
        return customerAddress;
    }
    
    public static Employee getEmployee(Map<String, String>values){
        Employee emp = new Employee();
        emp.setFirstName(values.get("firstName"));
        emp.setLastName(values.get("lastName"));
        emp.setContact(values.get("contact"));
        return emp;
    }
}
